﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.Entity;

namespace OnlineNewsEditorial_DaoLibrary.Impl
{
    public class JobDao : AbstractDao<Job>
    {
        public override List<Job> getAll()
        {
            try
            {
                var q = from j in _ctx.Jobs
                        select j;
                return q.ToList<Job>();
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public Job getById(String jobId)
        {
            try
            {
                var q = from j in _ctx.Jobs
                        where j.jobId == jobId
                        select j;
                return q.Single<Job>();
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public Job getByTitle(String jobTitle)
        {
            try
            {
                var q = from j in _ctx.Jobs
                        where j.jobTitle == jobTitle
                        select j;
                return q.Single<Job>();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
